package com.chenju.invokechainservice.test;

import java.util.*;

public class MethodImpactAnalysis {
    public static void main(String[] args) {
        List<String> deleteMethodList = Arrays.asList("deleteMethod1", "deleteMethod2");
        List<String> modifyMethodList = Arrays.asList("modifyMethod1", "modifyMethod2");
        List<String> addMethodList = Arrays.asList("addMethod1", "addMethod2");

        Map<String, Set<String>> interfaceToMethods = new HashMap<>();

        addToInterfaceMap(interfaceToMethods, "InterfaceA", deleteMethodList);
        addToInterfaceMap(interfaceToMethods, "InterfaceB", modifyMethodList);
        addToInterfaceMap(interfaceToMethods, "InterfaceC", modifyMethodList);
        addToInterfaceMap(interfaceToMethods, "InterfaceB", addMethodList);

        // Print the analysis
        for (Map.Entry<String, Set<String>> entry : interfaceToMethods.entrySet()) {
            System.out.println("Interface: " + entry.getKey());
            System.out.println("Impacted Methods: " + entry.getValue());
            System.out.println();
        }
    }

    private static void addToInterfaceMap(Map<String, Set<String>> interfaceMap, String iface, List<String> methods) {
        interfaceMap.computeIfAbsent(iface, k -> new HashSet<>()).addAll(methods);
    }
}


